using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ButtonSoundEffect : MonoBehaviour
{
    // button单机的音效
    public enum SoundList : int 
    {
        通用点击声,
        BuilldingLevelup,
        Click_Pop,
        ClickBack,
        EmployeePowerup,
        Pickup_Coins01,
        Pop,
        Special_Powerup_1,
        Special_Powerup_2,
        UI_DayEndWin,
        UI_Main_Loop,
    }
    [Header("当前音效")]
    public SoundList curSound;
    private string SoundName;
    public float volume = 0.8f;
    void Start()
    {
        Button btn = GetComponent<Button>();
        btn.onClick.AddListener(PlaySound);
        
    }

    void PlaySound()
    {
        if (curSound == SoundList.通用点击声) 
        {
            SoundName = AudioPlayerName.tyandj;
        }
        if (curSound == SoundList.BuilldingLevelup)
        {
            SoundName = AudioPlayerName.BuilldingLevelup;
        }
        if (curSound == SoundList.Click_Pop)
        {
            SoundName = AudioPlayerName.Click_Pop;
        }
        if (curSound == SoundList.ClickBack)
        {
            SoundName = AudioPlayerName.ClickBack;
        }
        if (curSound == SoundList.EmployeePowerup)
        {
            SoundName = AudioPlayerName.EmployeePowerup;
        }
        if (curSound == SoundList.Pickup_Coins01)
        {
            SoundName = AudioPlayerName.Pickup_Coins01;
        }
        if (curSound == SoundList.Pop)
        {
            SoundName = AudioPlayerName.Pop;
        }
        if (curSound == SoundList.Special_Powerup_1)
        {
            SoundName = AudioPlayerName.Special_1;
        }
        if (curSound == SoundList.Special_Powerup_2)
        {
            SoundName = AudioPlayerName.Special_2;
        }
        if (curSound == SoundList.UI_DayEndWin)
        {
            SoundName = AudioPlayerName.UI_Main_Loop;
        }

        AudioController.Instance.SoundPlay(SoundName, volume);
    }
}
